#pragma once
#include "Common/ComTypeDefine.h"
#include "Common/DuplicateDefine.h"
class IDuplicate;
struct IStar 
{
	virtual ~IStar(){};
	//初始化
	virtual bool init(IDuplicate *pDuplicate,int8_t idx, const VEC_INT32 &vecParam) = 0;
	//
	virtual void uninit() = 0;
	//类型
	virtual int8_t starType() = 0;
	//索引
	virtual int8_t starIdx() = 0;
	//是否完成星级条件
	virtual bool finishStar() = 0;
	//副本通关
	virtual void pass() {};
	//怪物死亡
	virtual void monsDead(uint32_t monsId, uint32_t monsNum,int32_t parentType){};
	//玩家死亡
	virtual void playerDead() {};
};


//副本星级A   1) 通关副本，无参数
class StarA : public IStar
{
public:
	StarA();
	virtual ~StarA();
	//初始化
	virtual bool init(IDuplicate *pDuplicate, int8_t idx, const VEC_INT32 &vecParam);
	//
	virtual void uninit();
	//类型
	virtual int8_t starType(){ return (int8_t)EDupStarType::EDupStarType_A; };
	//索引
	virtual int8_t starIdx() { return m_idx; }
	//是否完成星级条件
	virtual bool finishStar();
	//副本通关
	virtual void pass();
private:
	void notifyUpdate();
private:
	bool m_pass; //是否通关副本
	IDuplicate *m_pDuplicate;
	int8_t m_idx;
};

//副本星级B   2) 死亡次数不超过X次，1个参数（死亡次数）
class StarB : public IStar
{
public:
	StarB();
	virtual ~StarB();
	//初始化
	virtual bool init(IDuplicate *pDuplicate, int8_t idx, const VEC_INT32 &vecParam);
	//
	virtual void uninit();
	//类型
	virtual int8_t starType(){ return (int8_t)EDupStarType::EDupStarType_B; };
	//索引
	virtual int8_t starIdx() { return m_idx; }
	//是否完成星级条件
	virtual bool finishStar();
	//玩家死亡
	virtual void playerDead();
private:
	void notifyUpdate();
private:
	IDuplicate *m_pDuplicate;
	int32_t m_dieNum;
	int32_t m_curNum;
	int8_t m_idx;
};


//副本星级C   3) X秒内通关，1个参数（通关时间）
class StarC : public IStar
{
public:
	StarC();
	virtual ~StarC();
	//初始化
	virtual bool init(IDuplicate *pDuplicate, int8_t idx, const VEC_INT32 &vecParam);
	//
	virtual void uninit();
	//类型
	virtual int8_t starType(){ return (int8_t)EDupStarType::EDupStarType_C; };
	//索引
	virtual int8_t starIdx() { return m_idx; }
	//是否完成星级条件
	virtual bool finishStar();
	//副本通关
	virtual void pass();
private:
	void checkPass();
	void notifyUpdate();
private:
	IDuplicate *m_pDuplicate;
	int32_t m_sec;
	bool m_pass;
	int8_t m_idx;
};

//副本星级D   4) 消灭X个怪物Y，2个参数(X为怪物数量，Y为怪物ID)
class StarD : public IStar
{
public:
	StarD();
	virtual ~StarD();
	//初始化
	virtual bool init(IDuplicate *pDuplicate, int8_t idx, const VEC_INT32 &vecParam);
	//
	virtual void uninit();
	//类型
	virtual int8_t starType(){ return (int8_t)EDupStarType::EDupStarType_D; };
	//索引
	virtual int8_t starIdx() { return m_idx; }
	//是否完成星级条件
	virtual bool finishStar();
	//怪物死亡
	virtual void monsDead(uint32_t monsId, uint32_t monsNum, int32_t parentType);
private:
	void notifyUpdate();
private:
	IDuplicate *m_pDuplicate;
	uint32_t m_dstMonsId;
	int32_t m_dstNum;
	int32_t m_num;
	int8_t m_idx;
};


// /副本星级E  5) 消灭X个怪物（表示副本内的所有ID类型怪物），1个参数（怪物数量）
class StarE : public IStar
{
public:
	StarE();
	virtual ~StarE();
	//初始化
	virtual bool init(IDuplicate *pDuplicate, int8_t idx, const VEC_INT32 &vecParam);
	//
	virtual void uninit();
	//类型
	virtual int8_t starType(){ return (int8_t)EDupStarType::EDupStarType_E; };
	//索引
	virtual int8_t starIdx() { return m_idx; }
	//是否完成星级条件
	virtual bool finishStar();
	//怪物死亡
	virtual void monsDead(uint32_t monsId, uint32_t monsNum, int32_t parentType);
private:
	void notifyUpdate();
private:
	IDuplicate *m_pDuplicate;
	int32_t m_num;
	int32_t m_dstNum;
	int8_t m_idx;
	SET_INT32 m_setFilterType;
};


//副本星级 index - IStar*
typedef unordered_map<int8_t, IStar*> DupStarMap;

//副本星级
class DupStar
{
public:
	DupStar();
	~DupStar();
public:
	//初始化
	bool init(IDuplicate *pDuplicate,const VEC_VEC_INT32 *pStarCfg);
	//
	void uninit();
	//副本通关
	void pass();
	//怪物死亡
	void monsDead(uint32_t monsId, uint32_t monsNum,int32_t parentType);
	//玩家死亡
	void playerDead();
	//获取所有星级状态
	int8_t getStarState(MAP_INT8_INT8 &mapState);
private:
	DupStarMap m_mapStar;
};